fix(ui): avoid setState-in-effect in RunHistoryStrip to unblock lint (#357)#358
Conversation
There was a problem hiding this comment.
Sorry @w7-mgfcode, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Fixes the pre-existing
react-hooks/set-state-in-effecterror infrontend/src/components/demo/RunHistoryStrip.tsxthat made the whole-repopnpm lintgate (eslint .) red ondev.How
The effect appended a run-history entry by calling
setItems/setLastSummarysynchronously in its body. Refactored to:
renders" pattern (guarded
if (summary && summary !== lastSummary)), so nosetStatehappens inside an effect body.items— syncingReact state to an external system is the sanctioned use of an effect.
Behavior is unchanged: one history entry per
pipeline_completesummary,FIFO-capped at
HISTORY_CAP, persisted to the same versioned localStorage key.Validation
pnpm lint→ 0 errors (was 1 error; 1 unrelated pre-existing warning remains).pnpm tsc --noEmit→ clean.pnpm test --run→ all green;RunHistoryStrip.test.tsx5/5.Scope: one file. Closes #357.